home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / IC Component Debug ƒ / IC Switch Glue ƒ / IC Switch Glue.c
Encoding:
Text File  |  1995-12-02  |  13.3 KB  |  84 lines  |  [TEXT/SPM ]

  1. /*
  2.     IC Switch Glue.c
  3.     
  4.     Code to handle switching between the use of the component and the use of the linked-in
  5.     routines.
  6.     
  7.     I have implemented a small modification to the switch glue.  Basically from code the switch
  8.     can be controled to act in a certain manner.  For example, the code to call the component can
  9.     be turned off so that all calls made to the switch glue will always be handled by the linked in
  10.     code.  In fact, both the component and linked in code can be disabled causing the code to always
  11.     return without doing anything to the prefs whatsoever.
  12.     
  13.     I also modified the routines to return paramErr if a null ICInstance is passed as a parameter.
  14. */
  15.  
  16. #include <AppleTalk.h>
  17. #include <Aliases.h>
  18.  
  19. // include types and key information
  20. #include "IC Types.h"
  21. #include "IC Keys.h"
  22.  
  23. // include the main header for this file
  24. #include "IC API.h"
  25.  
  26. // include the headers for the component and resource routines
  27. #include "IC Component API.h"
  28. #include "IC Resource API.h"
  29.  
  30. // vars enabling/disabling the available code
  31. static Boolean gICSwitchCanUseComponent=true;
  32. static Boolean gICSwitchCanUseLinkIn=true;
  33.  
  34. OSErr ICEnableComponent(void){
  35.     gICSwitchCanUseComponent=true;
  36.     return noErr;
  37. }
  38.  
  39. OSErr ICDisableComponent(void){
  40.     gICSwitchCanUseComponent=false;
  41.     return noErr;
  42. }
  43.  
  44. OSErr ICEnableLinkedCode(void){
  45.     gICSwitchCanUseLinkIn=true;
  46.     return noErr;
  47. }
  48.  
  49. OSErr ICDisableLinkedCode(void){
  50.     gICSwitchCanUseLinkIn=false;
  51.     return noErr;
  52. }
  53.  
  54. Boolean ICComponentEnabled(void){
  55.     return gICSwitchCanUseComponent;
  56. }
  57.  
  58. Boolean ICLinkedCodeEnabled(void){
  59.     return gICSwitchCanUseLinkIn;
  60. }
  61.  
  62. Boolean ICUsingComponent(ICInstance inst){
  63.     ICRRecordPtr rp=(ICRRecordPtr)inst;
  64.     
  65.     // actually an error, but no way to return an error code
  66.     if (inst==(ICInstance)0)
  67.         return false;
  68.     
  69.     if (rp->instance!=(ComponentInstance)0)
  70.         return true;
  71.     return false;
  72. }
  73.  
  74. ICError ICStart(ICInstance* inst,OSType creator){
  75.     ICError err;
  76.     ICRRecordPtr instr;
  77.     
  78.     instr=(ICRRecordPtr)NewPtr(sizeof(ICRRecord));
  79.     err=MemError();
  80.     
  81.     if (err!=noErr)
  82.         return err;
  83.     
  84.     if (gICSwitchCanUseCompone